package com.etc.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etc.dao.RestaurantMapper;
import com.etc.entity.Restaurant;
import com.etc.utils.PageData;

/**
 * 餐厅管理的service实现类
 * 
 * @author Administrator
 *
 */
@Service(value = "restaurantService")
public class RestaurantServiceImpl implements com.etc.service.RestaurantService {
	@Resource
	private RestaurantMapper restrurantMapper;

	@Override
	public boolean addRestaurant(Restaurant restaurant) {
		int n = restrurantMapper.insertSelective(restaurant);
		return n > 0;
	}

	@Override
	public boolean delrestaurant(int rid) {
		int n = restrurantMapper.deleteByPrimaryKey(rid);
		return n > 0;
	}

	@Override
	public List<Restaurant> getRestaurant(int uid) {

		return restrurantMapper.getRestaurants2(uid);
	}

	@Override
	public List<Restaurant> getRestaurants() {

		return restrurantMapper.getRestaurants();
	}

	@Override
	public boolean updaterestaurant(Restaurant restaurant) {

		return restrurantMapper.updateByPrimaryKeySelective(restaurant) > 0;
	}

	@Override
	public List<Restaurant> getRestaurantByPage(Integer page, Integer limit) {
		int start = (page - 1) * limit;
		List<Restaurant> list = restrurantMapper.getRestaurantByPage(start, limit);
		return list;
	}

	@Override
	public int getcount() {
		return restrurantMapper.getCount();
	}

}
